﻿using AnesSystem.Models;
using AnesSystem.ViewModels.WorkScore;
using Common;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ExcelDll = Microsoft.Office.Interop.Excel;

namespace AnesSystem.Util
{

    /// <summary>
    /// 导出Excel类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="U"></typeparam>
    public class ExportToExcel
    {

        #region Variables

        private ExcelBasic excel;
        private static ExportToExcel _instance;


        public static string[] titles = {"麻醉例数", "ASA-I例数", "ASA-I死亡例数", "ASA-II例数", "ASA-II死亡例数", "ASA-III例数", "ASA-III死亡例数",
            "ASA-Ⅳ例数", "ASA-Ⅳ死亡例数", "ASA-Ⅴ例数", "ASA-Ⅴ死亡例数", "ASA-Ⅵ例数","更改手术方式","超声引导数","老年患者例数",
            "使用输注工作站数","血液(液体)加温治疗数","控制性降压治疗数","TEG数","术后镇痛PCIA数","术后镇痛PCEA数","术后镇痛未用PCA数",
            "全麻麻醉效果I级","全麻麻醉效果Ⅱ级","全麻麻醉效果Ⅲ级","椎管内麻醉效果I级","椎管内麻醉效果Ⅱ级","椎管内麻醉效果Ⅲ级","椎管内麻醉效果Ⅳ级","插管全麻例数", "非插管全麻例数",
            "病人去往病房数","病人去往复苏室数","病人去往ICU数", "体外循环例数", "椎管内麻醉例数", "插管全麻+椎管内例数",
            "静脉麻醉例数","神经阻滞数", "复合麻醉例数", "其他麻醉例数",
            "急诊手术例数", "术后镇痛例数", "心肺复苏数", "复苏成功数","用血例数","用血合理数", "进入PACU数", "Steward评分≥4例数",
            "急性失血>1600ml","剖宫产手术时间>3小时","非手术范围器官及组织损伤",
            "意外死亡例数", "未预期意识障碍数", "氧饱和度重度降低数", "结束时使用催醒药物数", "因误咽误吸引发呼吸道梗阻数",
            "其他非预期相关事件数", "静脉PCA数", "皮下PCA数", "硬膜外PCA数", "神经丛PCA数",
            "中心静脉穿刺数", "颈内静脉穿刺数", "锁骨上深静脉穿刺数", "锁骨下深静脉穿刺数", "股静脉穿刺数",
            "动脉穿刺数","桡动脉穿刺数", "足背动脉穿刺数", "有创动脉穿刺严重并发症","麻醉后手术取消数", "PACU转出延迟数", "PACU入室低温数",
            "非计划转入ICU数", "非计划二次插管数", "非计划二次手术数", "非计划二次麻醉数", "非计划改变麻醉方式数", "术中输血输液反应数",
            "麻醉后24小时内死亡数", "麻醉后24小时内心跳骤停数", "术中自体血输注数", "麻醉期间严重过敏数","术中严重低血压数",
            "椎管内麻醉严重神经并发症数", "中心静脉穿刺严重并发症数", "全麻气管插管拔管后声音嘶哑数",
            "麻醉后新发昏迷数",
            "手术切口分类I","手术切口分类Ⅱ","手术切口分类Ⅲ","手术切口分类Ⅳ",
            "浅层组织手术","深部组织手术","器官手术","腔隙内手术", "重大手术","穿破硬脊膜","术中知晓","手术室内医疗干预",
            "麻醉后头痛", "穿刺点红肿流液", "多次插管", "多次穿刺", "恶心呕吐", "肢体活动障碍","其它"};

        public static string[] methods = {"MaZuiCount", "ASA1", "ASA1Dead", "ASA2", "ASA2Dead", "ASA3", "ASA3Dead",
            "ASA4", "ASA4Dead", "ASA5", "ASA5Dead", "ASA6","GengGaiShouShuMethod","ChaoShengYinDao","LaoNianHuanZhe",
            "ShiYongShuZhuGongZuoZhan","XueYeJiaWenZhiLiao","KongZhiXingJiangYa", "Teg","Pcia","Pcea","NoPca",
            "QuanMaXiaoGuo1","QuanMaXiaoGuo2","QuanMaXiaoGuo3", "ZhuiGuanNeiXiaoGuo1","ZhuiGuanNeiXiaoGuo2","ZhuiGuanNeiXiaoGuo3","ZhuiGuanNeiXiaoGuo4","ChaGuanQuanMaCount", "FeiChaGuanQuanMaCount",
            "PatToBf","PatToPacu","PatToIcu","TiWaiXunHuan", "ZhuiGuanNeiMaZauiCount", "ChaGuanQuanMaAndZhuiGuan",
            "JingMaiMaZuiConut","ShenJingZuZhi","FuHeMaZuiCount","QiTaMaZuiCount",
            "JiZhen","ShuHouZhenTong","XinFeiFuSu","FuSuChengGong","YongXueShu","YongXueHeLiShu","PACUCount","StewardBig4",
            "JiXingShiXue","PouGongChanShouShu","NotShouShuFanWeiQiGuanSunShang",
            "YiWaiDead","WeiYuQiYiShi","Spo2JiangDi","UseCuiXingDrug","HuXiDaoGengZu",
            "OtherFeiYuQiShiJian","JingMaiPCA", "PiXiaPCA","YingMoWaiPCA","ShengJingCongPCA",
            "ZhongXinJingMaiChuanCi","JingNeiJingMaiChuanCi","SuoGuShangJingMaiChuanCi", "SuoGuXiaJingMaiChuanCi",
            "GuJingMaiChuanCi","DongMaiChuanCi", "NaoDongMaiChuanCi", "ZuBeiDongMaiChuanCi","YouChuangDongMaiCCBingFa",
            "CancelShouShu","ZhuanChuYanChi","DiTiWen",
            "ZhuanRuICU","ErCiChaGuan","NotPlan2ShouShu","NotPlan2Mazui","NotPlan2MazuiFangShi","ShuZhongShuXueShuYeFY",
            "SiWang","XinTiaoStop","ZiTiXueShuZhu","GuoMinYanZhong","ShuZhongDiXueYa",
            "ShenJingBingFa","JingMaiChuanCiBingFa","QiGuanShengSi",
            "HunMi",
            "OperType1","OperType2","OperType3","OperType4",
            "QianCengZuZhi","ShenBuZuZhi","QiGuan","QiangXiNei", "ZhongDaShouShu","ChuanPoYingJiMo","ShuZhongZhiXiao","ShouShuShiYiLiaoGanYu",
            "MazuiHouTouTong", "ChuanCiDianHongZong", "DuoCiChaGuan", "DuoCiChuanCi", "eXinOuTu", "ZhiTiZangAi","QiTa"};

        public static DateTime[] months = new DateTime[12];


        string[] header = new string[]{"日期", "姓名", "性别", "年龄", "科别+床号", "住院号", "手术名称", "ASA\n分级",
                                    "急诊", "特殊情况", "麻醉医生", "查对"};
        string[] header1 = new string[] { "麻醉方式", "血管穿刺", "镇痛泵", "病人去向", "麻醉质控", "入室时间", "出室时间", "入室时长（分）", "手术开始", "手术结束", "手术时长(分)" };
        string[] headerMazuiMethod = new string[] { "普通\n插管\n全麻", "单腔\n管全\n麻", "双腔\n管全\n麻", "喉罩\n插管\n全麻", "异型\n管全\n麻", "硬外\n膜", "腰麻", "腰硬\n联合", "神经\n阻滞", "静脉\n全麻", "局麻", "复合\n麻醉", "静\n脉", "动\n脉", "静\n脉", "硬\n外\n膜" };
        string[] headerQuXiang = new string[] { "PACU", "病\n房", "ICU" ,"重大\n手术","非计划\n二次手\n术", "非计划\n二次插\n管", "非计划\n改变麻\n醉方式",
                                    "非计划\n二次麻\n醉", "术中输\n血、输\n液反应", "术后意\n识障碍",
                                    "术后氧\n饱和度\n重度降\n低", "误吸所\n致呼吸\n道梗阻", "术中、\n术后心\n肺复苏"};


        string[] workHeader = new string[]{"医生", "工作基本分", "ASAⅢ级以上", "剖宫产", "区域麻醉", "全身麻醉", "术前访视", "无痛胃镜", "无痛人流",
                                    "无痛肠镜+氩气刀", "深静脉置管", "动脉置管测压", "科外急诊抢救", "院内会诊", "合计"};
        string[] workHeader2 = new string[] { "分值", "3分/小时", "3分/例", "1分/例", "2分/例", "4分/例", "0.5分/例", "0.7分/例", "1分/例", "2分/例", "2分/例", "2分/例", "2分/例", "2分/例", "2分/例" };

        private static string[] HistoryHeader = new string[] {  "时间", "手术间", "姓名", "性别", "年龄", "身高", "体重", "科室,", "床号", "住院号", "临床诊断", "实施手术","ASA分级",
            "NYHA","中心静脉监测","动脉穿刺","术中输血","术后镇痛","病人去向","血液回输治疗","非计划性二次手术","手术开始","手术结束","手术时长","失血量","手术费用","洗手1","洗手2","巡回1","巡回2","主刀医师",
            "助手","麻醉医师（主麻、副麻）","麻醉方式","既往史","steward评分","麻醉效果","备注","手术类型"};

        private static string[] OperationNoticHeader = new string[]{"","序号", "手术间",  "科室","床号","病人姓名", "性别", "年龄", "住院号",  "手术名称", "手术医生",
                                    "麻醉方式", "麻醉医生", "器械护士", "巡回护士", "备注"};
        private static string[] OtherStatisticscHeader = new string[] { "", "序号", "手术间", "手术日期", "病人姓名", "科室", "性别", "年龄", "病历号", "术后诊断", "手术名称", "手术医生", "麻醉方式", "麻醉医生", "特殊情况" };
        private static string[] DurationStatisticsHeader = new string[] { "", "序号", "手术间", "手术日期", "姓名", "科室", "性别", "年龄", "病历号", "麻醉方式", "入手术室-麻醉开始", "时长", "麻醉开始-手术开始", "手术开始-手术结束", "手术时长", "手术结束-麻醉结束", "麻醉时长", "麻醉结束-出手术室", "时长", "手术名称", "主刀医生", "主麻医生" };

        #endregion

        #region Constructor

        public ExportToExcel()
        {
            excel = Activator.CreateInstance(Type.GetType(HospitalConfig.Instance.CurrentHospital.ExcelClassName)) as ExcelBasic;
        }


        #endregion

        #region Properties

        public ExcelBasic Excel
        {
            get
            {
                return excel;
            }
        }
        #endregion

        #region 依赖属性

        #endregion

        #region Event

        #endregion

        #region Private Methods

        #endregion

        #region Public/Protected Methods

        #endregion

        #region EventHandlers

        #endregion



        public static ExportToExcel Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new ExportToExcel();
                }
                return _instance;
            }
        }

        public void ExportParameterCommon(string titleName, List<PatientLinkModel> patientLinkList)
        {
            string fileName = titleName;
            string saveFileName = titleName;
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.DefaultExt = "xlsx";
            saveDialog.Filter = "Excel 文件|*.xlsx";
            saveDialog.FileName = fileName;
            if (!(bool)saveDialog.ShowDialog()) return;
            saveFileName = saveDialog.FileName;

            try
            {
                Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

                if (xlApp == null)
                {
                    MessageBoxCommon.ShowDialog("无法创建Excel对象，您可能未安装Excel!", MessageBoxCommon.OK);
                    return;
                }
                Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks;
                Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);

                Microsoft.Office.Interop.Excel.Worksheet worksheet = ExportParameteraksuhfb(workbook, fileName, patientLinkList);

                //写入行
                worksheet.Columns.EntireColumn.AutoFit();
                try
                {
                    //MessageBoxCommon.ShowDialog(fileName + "保存成功", MessageBoxCommon.OK);
                    if (saveFileName != "")
                    {
                        workbook.Saved = true;
                        workbook.SaveCopyAs(saveFileName);
                    }
                }
                catch (Exception ex)
                {
                    //MessageBoxCommon.ShowDialog("保存成功导出文件可能正在被打断", MessageBoxCommon.OK);
                }

                xlApp.Quit();
                GC.Collect();
            }
            catch (Exception ex)
            {
                Common.LogHelper.Error(GetType(), ex);
                MessageBoxCommon.ShowDialog("无法创建Excel对象，您可能未安装Excel!", 0);
            }
        }

        private static ExcelDll.Worksheet ExportParameteraksuhfb(ExcelDll.Workbook workbook, string fileName, List<PatientLinkModel> patientLinkList)
        {
            ExcelDll.Worksheet worksheet = (ExcelDll.Worksheet)workbook.Worksheets[1]; //取得sheet1
            patientLinkList = patientLinkList.OrderBy(u => u.Status.InRoomTime).ToList();
            if (fileName.Equals("历史手术"))
            {
                worksheet = merge(worksheet, fileName, 1, 1, 1, 13);
                if (HospitalConfig.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_CQ_NTZYY))
                {
                    HistoryHeader = new string[] {  "时间", "手术间", "姓名", "性别", "年龄", "身高", "体重", "科室,", "床号", "住院号", "临床诊断", "实施手术","ASA分级",
            "NYHA","中心静脉监测","动脉穿刺","术中输血","术后镇痛","病人去向","血液回输治疗","非计划性二次手术","入室时间","出室时间","手术时长","失血量","手术费用","洗手1","洗手2","巡回1","巡回2","主刀医师",
            "助手","麻醉医师（主麻、副麻）","麻醉方式","既往史","steward评分","麻醉效果","备注","手术类型","动脉穿刺","血气分析","中心静脉穿刺","漂浮导管","超声引导","神经刺激仪","可视喉镜引导","使用输注工作站",
            "血液(液体)加温治疗","血液回输治疗","控制性降压治疗","非计划二次麻醉","非计划改变麻醉方式","非计划二次手术","非计划二次气管插管","麻醉后手术取消","非计划转入ICU发生","其他非预期相关事件","更改手术方式"};
                }
                for (int i = 1; i < HistoryHeader.Length; i++)
                {
                    worksheet.Cells[2, i + 1] = HistoryHeader[i];
                }
                for (int i = 0; i < patientLinkList.Count; i++)
                {
                    worksheet.Cells[i + 3, 1] = patientLinkList[i].Status.InRoomTime.ToShortDateString().ToString();
                    worksheet.Cells[i + 3, 2] = patientLinkList[i].Schedule.Pbssjh;
                    worksheet.Cells[i + 3, 3] = patientLinkList[i].Patient.Brxm;
                    worksheet.Cells[i + 3, 4] = patientLinkList[i].Patient.Xb;
                    worksheet.Cells[i + 3, 5] = patientLinkList[i].Patient.Nl;
                    worksheet.Cells[i + 3, 6] = patientLinkList[i].Patient.Sg + "cm";
                    worksheet.Cells[i + 3, 7] = patientLinkList[i].Patient.Tz + "kg";
                    worksheet.Cells[i + 3, 8] = patientLinkList[i].Patient.Ksmc;
                    worksheet.Cells[i + 3, 9] = patientLinkList[i].Patient.Zych;
                    worksheet.Cells[i + 3, 10] = patientLinkList[i].Patient.Zyh;
                    worksheet.Cells[i + 3, 11] = patientLinkList[i].Application.Sqzd1;
                    worksheet.Cells[i + 3, 12] = patientLinkList[i].Application.Nsssmc;

                    worksheet.Cells[i + 3, 13] = patientLinkList[i].AnesthesiaRecord.Asa.Level;
                    worksheet.Cells[i + 3, 14] = patientLinkList[i].AnesthesiaRecord.Nyha;
                    worksheet.Cells[i + 3, 15] = getBol(patientLinkList[i].AnesthesiaRecord.Zxjmcc);
                    worksheet.Cells[i + 3, 16] = getBol(patientLinkList[i].AnesthesiaRecord.Dmcc);
                    worksheet.Cells[i + 3, 17] = patientLinkList[i].AnesthesiaRecord.LiquidInAndOut.XueJiang + "+" + patientLinkList[i].AnesthesiaRecord.LiquidInAndOut.Rbc;
                    worksheet.Cells[i + 3, 18] = patientLinkList[i].AnesthesiaRecord.PCIA ? "PCIA" : patientLinkList[i].AnesthesiaRecord.PCEA ? "PCEA" : patientLinkList[i].AnesthesiaRecord.PCNA ? "PCNA" : "未用PCA";
                    worksheet.Cells[i + 3, 19] = patientLinkList[i].AnesthesiaRecord.Brqw;
                    worksheet.Cells[i + 3, 20] = getBol(patientLinkList[i].AnesthesiaRecord.Xyhszl);
                    worksheet.Cells[i + 3, 21] = getBol(patientLinkList[i].QualityPojo.Fjhecss);

                    worksheet.Cells[i + 3, 22] = string.Format("{0:g}", patientLinkList[i].Status.InRoomTime);
                    worksheet.Cells[i + 3, 23] = string.Format("{0:g}", patientLinkList[i].Status.OutRoomTime);

                    long timeGap = 0;
                    DateTime mazuiStartTime = patientLinkList[i].Status.InRoomTime;
                    DateTime mazuiEndTime = patientLinkList[i].Status.OutRoomTime;
                    if (mazuiStartTime != null && mazuiEndTime != null)
                    {
                        timeGap = (long)(mazuiEndTime - mazuiStartTime).TotalSeconds;
                    }
                    worksheet.Cells[i + 3, 24] = timeGap / 60 + "分";
                    worksheet.Cells[i + 3, 25] = patientLinkList[i].AnesthesiaRecord.LiquidInAndOut.Sxl + "ml";
                    worksheet.Cells[i + 3, 26] = "";
                    worksheet.Cells[i + 3, 27] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.Xshs1);
                    worksheet.Cells[i + 3, 28] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.Xshs2);
                    worksheet.Cells[i + 3, 29] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.Xhhs1);
                    worksheet.Cells[i + 3, 30] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.Xhhs2);
                    worksheet.Cells[i + 3, 31] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.OperDoctor1);
                    worksheet.Cells[i + 3, 32] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.OperDoctor1Assistant1);
                    worksheet.Cells[i + 3, 33] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.Zmys) + DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.Fmys1);
                    worksheet.Cells[i + 3, 34] = patientLinkList[i].AnesthesiaRecord.Mzff;

                    string jwsStr = ""; //既往史
                    try
                    {
                        bool a1 = false;
                        List<string> jwss = DataManager.Instance.GetXMLTableValue(patientLinkList[i], "NanTongShuQianFangShi",
                            new string[] { "gxy", "gxb", "tnb", "mxzsxfy", "xc", "nxs", "ncx", "dx", "sss", "mzs", "wss", "gms", "sxs", "xys", "yjy", "jzs" });
                        if (jwss.Count == 16)
                        {
                            bool.TryParse(jwss[0], out a1); jwsStr += (!a1 ? "" : "高血压  ");
                            bool.TryParse(jwss[1], out a1); jwsStr += (!a1 ? "" : "冠心病  ");
                            bool.TryParse(jwss[2], out a1); jwsStr += (!a1 ? "" : "糖尿病  ");
                            bool.TryParse(jwss[3], out a1); jwsStr += (!a1 ? "" : "慢性阻塞性肺炎  ");
                            bool.TryParse(jwss[4], out a1); jwsStr += (!a1 ? "" : "哮喘  ");
                            bool.TryParse(jwss[5], out a1); jwsStr += (!a1 ? "" : "脑血塞  ");
                            bool.TryParse(jwss[6], out a1); jwsStr += (!a1 ? "" : "脑出血  ");
                            bool.TryParse(jwss[7], out a1); jwsStr += (!a1 ? "" : "癫痫  ");
                            bool.TryParse(jwss[8], out a1); jwsStr += (!a1 ? "" : "手术史  ");
                            bool.TryParse(jwss[9], out a1); jwsStr += (!a1 ? "" : "麻醉史  ");
                            bool.TryParse(jwss[10], out a1); jwsStr += (!a1 ? "" : "外伤史  ");
                            bool.TryParse(jwss[11], out a1); jwsStr += (!a1 ? "" : "过敏史  ");
                            bool.TryParse(jwss[12], out a1); jwsStr += (!a1 ? "" : "输血史  ");
                            bool.TryParse(jwss[13], out a1); jwsStr += (!a1 ? "" : "吸烟史  ");
                            bool.TryParse(jwss[14], out a1); jwsStr += (!a1 ? "" : "已戒烟  ");
                            bool.TryParse(jwss[15], out a1); jwsStr += (!a1 ? "" : "家族史  ");
                            //jwsStr += (null == jwss[16] ? "" : "\r\n特殊情况:" + jwss[16] + "\r\n");
                        }
                    }
                    catch (Exception)
                    {

                    }
                    worksheet.Cells[i + 3, 35] = jwsStr;//
                    worksheet.Cells[i + 3, 36] = patientLinkList[i].AnesthesiaRecord.Sxpf;
                    if (patientLinkList[i].AnesthesiaRecord.ComplicatedMethod.Zm1)
                    {
                        worksheet.Cells[i + 3, 37] = "优";
                    }
                    else if (patientLinkList[i].AnesthesiaRecord.ComplicatedMethod.Zm2)
                    {
                        worksheet.Cells[i + 3, 37] = "良";
                    }
                    else if (patientLinkList[i].AnesthesiaRecord.ComplicatedMethod.Zm3)
                    {
                        worksheet.Cells[i + 3, 37] = "差";
                    }

                    string bz = "";
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjl1)
                    {
                        bz += "欠平顺,血液动力学波动明显，20%-40%。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjl2)
                    {
                        bz += "血液动力学液动明显，内环境欠稳定，手术条件欠佳。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjl3)
                    {
                        bz += "轻度躁动，苏醒延迟，残余肌松或应激反应。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjl4)
                    {
                        bz += "轻微并发症。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjc1)
                    {
                        bz += "不平顺,血液动力学波动剧烈，>40%";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjc2)
                    {
                        bz += "血液动力学液动剧烈，内环境不稳定，手术条件差。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjc3)
                    {
                        bz += "重度躁动，苏醒延迟，残余肌松或应激反应。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qmpjc4)
                    {
                        bz += "术中知晓，心脑血管，意外等。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjll)
                    {
                        bz += "镇痛、镇静、肌松能满足手术要求，手术医生反应一般。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjl2)
                    {
                        bz += "诉轻度疼痛或不适感，伴恶心、呕吐。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjl3)
                    {
                        bz += "有明显波动。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjl4)
                    {
                        bz += "轻微并发症";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjc1)
                    {
                        bz += "镇痛、镇静、肌松差，不能满足手术要求，手术医生反应一般。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjc2)
                    {
                        bz += "剧烈疼痛或不适，无法忍受。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjc3)
                    {
                        bz += "有剧烈波动。";
                    }
                    if (patientLinkList[i].AnesthesiaRecord.Qymzpjc4)
                    {
                        bz += "全脊麻，神经损害，心脑血管意外等。";
                    }
                    worksheet.Cells[i + 3, 38] = bz;
                    if (patientLinkList[i].AnesthesiaRecord.Asa.Jz)
                    {
                        worksheet.Cells[i + 3, 39] = "急诊";
                    }
                    else
                    {
                        worksheet.Cells[i + 3, 39] = "择期";
                    }
                    if (HospitalConfig.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_CQ_NTZYY))
                    {
                        if (patientLinkList[i].AnesthesiaRecord.Dmcc)
                        {
                            worksheet.Cells[i + 3, 40] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Xqfx)
                        {
                            worksheet.Cells[i + 3, 41] = "是：" + patientLinkList[i].AnesthesiaRecord.Xqfxnr;
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Zxjmcc)
                        {
                            worksheet.Cells[i + 3, 42] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Pfdg)
                        {
                            worksheet.Cells[i + 3, 43] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Csyd)
                        {
                            worksheet.Cells[i + 3, 44] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Sjcjy)
                        {
                            worksheet.Cells[i + 3, 45] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Ztqyzl)
                        {
                            worksheet.Cells[i + 3, 46] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Sygzz)
                        {
                            worksheet.Cells[i + 3, 47] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Jwzl)
                        {
                            worksheet.Cells[i + 3, 48] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Xyhszl)
                        {
                            worksheet.Cells[i + 3, 49] = "是";
                        }
                        if (patientLinkList[i].AnesthesiaRecord.Jyzl)
                        {
                            worksheet.Cells[i + 3, 50] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.Fjhecmz)
                        {
                            worksheet.Cells[i + 3, 51] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.Fjhgbmzfs)
                        {
                            worksheet.Cells[i + 3, 52] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.Fjhecss)
                        {
                            worksheet.Cells[i + 3, 53] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.Fjhecqgcg)
                        {
                            worksheet.Cells[i + 3, 54] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.Mzhssqx)
                        {
                            worksheet.Cells[i + 3, 55] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.FjhzrICUfs)
                        {
                            worksheet.Cells[i + 3, 56] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.Qtfyqxgsj)
                        {
                            worksheet.Cells[i + 3, 57] = "是";
                        }
                        if (patientLinkList[i].QualityPojo.Ggssfs)
                        {
                            worksheet.Cells[i + 3, 58] = "是";
                        }
                    }
                }

            }
            else if (fileName.Equals("手术通知单"))
            {
                worksheet = merge(worksheet, fileName, 1, 1, 1, 16);

                for (int i = 0; i < OperationNoticHeader.Length; i++)
                {
                    worksheet.Cells[2, i + 1] = OperationNoticHeader[i];
                }
                for (int i = 1; i < patientLinkList.Count; i++)
                {
                    worksheet.Cells[i + 3, 2] = i;
                    worksheet.Cells[i + 3, 3] = patientLinkList[i].Schedule.Pbssjh;
                    worksheet.Cells[i + 3, 4] = patientLinkList[i].Patient.Ksmc;
                    worksheet.Cells[i + 3, 5] = patientLinkList[i].Patient.Zych;
                    worksheet.Cells[i + 3, 6] = patientLinkList[i].Patient.Brxm;
                    worksheet.Cells[i + 3, 7] = patientLinkList[i].Patient.Xb;
                    worksheet.Cells[i + 3, 8] = patientLinkList[i].Patient.Nl;
                    worksheet.Cells[i + 3, 9] = patientLinkList[i].Patient.Zyh;
                    worksheet.Cells[i + 3, 10] = patientLinkList[i].Application.Nsssmc;
                    worksheet.Cells[i + 3, 11] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Application.Ssysxm);
                    worksheet.Cells[i + 3, 12] = patientLinkList[i].Schedule.Mzfs;
                    worksheet.Cells[i + 3, 13] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Schedule.ToAnesDoctor);
                    worksheet.Cells[i + 3, 14] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Schedule.Qxhsbh1);
                    worksheet.Cells[i + 3, 15] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Schedule.Xhhsbh1);
                    worksheet.Cells[i + 3, 16] = patientLinkList[i].Schedule.Bznr;
                }
            }
            else if (fileName.Equals("时长"))
            {
                worksheet = merge(worksheet, fileName, 1, 1, 1, 16);

                for (int i = 0; i < DurationStatisticsHeader.Length; i++)
                {
                    worksheet.Cells[2, i + 1] = DurationStatisticsHeader[i];
                }
                for (int i = 1; i < patientLinkList.Count; i++)
                {
                    worksheet.Cells[i + 3, 2] = i;
                    worksheet.Cells[i + 3, 3] = patientLinkList[i].Schedule.Pbssjh;
                    worksheet.Cells[i + 3, 4] = patientLinkList[i].Patient.Ksmc;
                    worksheet.Cells[i + 3, 5] = patientLinkList[i].Patient.Zych;
                    worksheet.Cells[i + 3, 6] = patientLinkList[i].Patient.Brxm;
                    worksheet.Cells[i + 3, 7] = patientLinkList[i].Patient.Xb;
                    worksheet.Cells[i + 3, 8] = patientLinkList[i].Patient.Nl;
                    worksheet.Cells[i + 3, 9] = patientLinkList[i].Patient.Zyh;
                    worksheet.Cells[i + 3, 10] = patientLinkList[i].Application.Nsssmc;
                    worksheet.Cells[i + 3, 11] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Application.Ssysxm);
                    worksheet.Cells[i + 3, 12] = patientLinkList[i].Schedule.Mzfs;
                    worksheet.Cells[i + 3, 13] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Schedule.ToAnesDoctor);
                    worksheet.Cells[i + 3, 14] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Schedule.Qxhsbh1);
                    worksheet.Cells[i + 3, 15] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].Schedule.Xhhsbh1);
                    worksheet.Cells[i + 3, 16] = patientLinkList[i].Schedule.Bznr;
                }
            }
            else
            {
                if (HospitalConfig.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_SC_SCDC))
                {
                    OtherStatisticscHeader = new string[] { "", "序号", "手术间", "手术日期", "病人姓名", "科室", "性别", "年龄", "病历号", "术后诊断", "手术名称", "手术医生", "麻醉方式", "麻醉医生", "特殊情况", "工分" };
                }
                worksheet = merge(worksheet, fileName, 1, 1, 1, 16);

                for (int i = 0; i < OtherStatisticscHeader.Length; i++)
                {
                    worksheet.Cells[2, i + 1] = OtherStatisticscHeader[i];
                }
                for (int i = 1; i < patientLinkList.Count; i++)
                {
                    worksheet.Cells[i + 3, 2] = i;
                    worksheet.Cells[i + 3, 3] = patientLinkList[i].Schedule.Pbssjh;
                    worksheet.Cells[i + 3, 4] = patientLinkList[i].Status.InRoomTime;
                    worksheet.Cells[i + 3, 5] = patientLinkList[i].Patient.Brxm;
                    worksheet.Cells[i + 3, 6] = patientLinkList[i].Patient.Ksmc;
                    worksheet.Cells[i + 3, 7] = patientLinkList[i].Patient.Xb;
                    worksheet.Cells[i + 3, 8] = patientLinkList[i].Patient.Nl;
                    worksheet.Cells[i + 3, 9] = patientLinkList[i].Patient.Zyh;
                    worksheet.Cells[i + 3, 10] = patientLinkList[i].AnesthesiaRecord.Shzd1;
                    worksheet.Cells[i + 3, 11] = patientLinkList[i].AnesthesiaRecord.Ysss1;
                    worksheet.Cells[i + 3, 12] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.OperDoctor1);
                    worksheet.Cells[i + 3, 13] = patientLinkList[i].AnesthesiaRecord.Mzff;
                    worksheet.Cells[i + 3, 14] = DataManager.Instance.GetAccountNameByID(patientLinkList[i].AnesthesiaRecord.Zmys);
                    worksheet.Cells[i + 3, 15] = patientLinkList[i].AnesthesiaRecord.Tsqk;
                    if (HospitalConfig.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_SC_SCDC))
                    {
                        worksheet.Cells[i + 3, 16] = patientLinkList[i].Gongfen.Total;
                    }
                }
            }

            return worksheet;
        }


        public static string getBol(Boolean bol)
        {
            if (bol)
            {
                return "是";
            }
            else
            {
                return "否";
            }
        }


        public void exportTongLiangExcel(DateTime startTime, DateTime endTime, string accountName)
        {
            string fileName = startTime.Year.ToString() + "年麻醉工作量统计";
            string saveFileName = startTime.Year.ToString() + "年麻醉工作量统计";
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.DefaultExt = "xlsx";
            saveDialog.Filter = "Excel 文件|*.xlsx";
            saveDialog.FileName = fileName;
            saveDialog.ShowDialog();
            saveFileName = saveDialog.FileName;
            if (saveFileName.IndexOf(":") < 0) return;  //被点了取消
            ExcelDll.Application xlApp = new ExcelDll.Application();
            if (xlApp == null)
            {
                MessageBoxCommon.ShowDialog("无法创建Excel对象，您可能未安装Excel!", MessageBoxCommon.OK);
                return;
            }
            ExcelDll.Workbooks workbooks = xlApp.Workbooks;
            ExcelDll.Workbook workbook = workbooks.Add(ExcelDll.XlWBATemplate.xlWBATWorksheet);
            ExcelDll.Worksheet worksheet = (ExcelDll.Worksheet)workbook.Worksheets[1]; //取得sheet1


            //Borders.LineStyle 单元格边框线
            ExcelDll.Range excelRange = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[1, 41]];

            //单元格边框线类型(线型,虚线型)
            //excelRange.Borders.LineStyle = 1;
            //excelRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlContinuous;
            //指定单元格下边框线粗细,和色彩
            //excelRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom).Weight = Excel.XlBorderWeight.xlMedium;
            //excelRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom).ColorIndex = 3;

            //设置字体大小
            excelRange.Font.Size = 20;
            excelRange.Font.Bold = true;
            //excelRange.Font.Color = new SolidColorBrush(Colors.Red);
            //excelRange.Font.ColorIndex = new SolidColorBrush(Colors.Red);
            //设置字体是否有下划线
            //excelRange.Font.Underline = true;

            //设置字体在单元格内的对其方式
            excelRange.HorizontalAlignment = ExcelDll.XlHAlign.xlHAlignCenter;
            //设置单元格的宽度
            //excelRange.ColumnWidth = 15;
            //设置单元格的背景色
            //excelRange.Cells.Interior.Color = System.Drawing.Color.FromArgb(255, 204, 153).ToArgb();
            //// 给单元格加边框
            //excelRange.BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlThick,
            //                                          Excel.XlColorIndex.xlColorIndexAutomatic, System.Drawing.Color.Black.ToArgb());
            //自动调整列宽
            excelRange.EntireColumn.AutoFit();
            //文本自动换行
            excelRange.WrapText = true;
            //填充颜色为淡紫色
            //excelRange.Interior.ColorIndex = 39;

            //合并单元格
            excelRange.Merge(excelRange.MergeCells);
            worksheet.Cells[1, 1] = fileName;
            for (int i = 0; i < 9; i++)//header标题合并单元格
            {
                worksheet = merge(worksheet, header[i], 2, i + 1, 3, i + 1);
            }
            worksheet = merge(worksheet, "麻醉方式", 2, 10, 2, 21);
            worksheet = merge(worksheet, "血管穿刺", 2, 22, 2, 23);
            worksheet = merge(worksheet, "镇痛泵", 2, 24, 2, 25);
            worksheet = merge(worksheet, "特殊情况", 2, 26, 3, 26);
            worksheet = merge(worksheet, "病人去向", 2, 27, 2, 29);
            worksheet = merge(worksheet, "麻醉质控", 2, 30, 2, 39);
            worksheet = merge(worksheet, "麻醉医生", 2, 40, 3, 40);
            worksheet = merge(worksheet, "查对", 2, 41, 3, 41);
            worksheet = merge(worksheet, "入手术室时间", 2, 42, 3, 42);
            worksheet = merge(worksheet, "出手术室时间", 2, 43, 3, 43);
            worksheet = merge(worksheet, "入室时长", 2, 44, 3, 44);
            worksheet = merge(worksheet, "手术开始时间", 2, 45, 3, 45);
            worksheet = merge(worksheet, "手术结束时间", 2, 46, 3, 46);
            worksheet = merge(worksheet, "手术时长", 2, 47, 3, 47);
            for (int i = 0; i < headerMazuiMethod.Length; i++)//header标题合并单元格
            {
                worksheet.Cells[3, i + 10] = headerMazuiMethod[i];
            }
            for (int i = 0; i < headerQuXiang.Length; i++)//header标题合并单元格
            {
                worksheet.Cells[3, i + 27] = headerQuXiang[i];
            }

            Dictionary<int, Dictionary<int, string>> rowMapColData = QualityWorkExport.CalData(startTime, endTime, accountName);
            for (int row = 0; row < rowMapColData.Count; row++)
            {
                Dictionary<int, string> colMapData = rowMapColData[row];
                for (int col = 0; col < 60; col++)
                {
                    if (colMapData.ContainsKey(col))
                    {
                        string data = colMapData[col];
                        if (null == data || data.Length == 0) continue;
                        //Label colData = new Label(col + 1, row + 3, data, wcf_cell);
                        worksheet.Cells[row + 4, col + 1] = data;
                    }
                }
            }

            worksheet.Columns.EntireColumn.AutoFit();
            //MessageBoxCommon.ShowDialog(fileName + "保存成功", MessageBoxCommon.OK);
            if (saveFileName != "")
            {
                try
                {
                    workbook.Saved = true;
                    workbook.SaveCopyAs(saveFileName);
                }
                catch (Exception ex)
                {
                    MessageBoxCommon.ShowDialog("导出文件可能正在被打断!" + ex.Message, MessageBoxCommon.OK);
                }
            }
            xlApp.Quit();
            GC.Collect();
        }

        public void exportWorkScoreExcel(Dictionary<DateTime, List<WorkScoreModel>> allWoekScoreList)
        {
            string fileName = "麻醉量化分登记";
            string saveFileName = "麻醉量化分登记";
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.DefaultExt = "xlsx";
            saveDialog.Filter = "Excel 文件|*.xlsx";
            saveDialog.FileName = fileName;
            saveDialog.ShowDialog();
            saveFileName = saveDialog.FileName;
            if (saveFileName.IndexOf(":") < 0) return;  //被点了取消
            ExcelDll.Application xlApp = new ExcelDll.Application();
            if (xlApp == null)
            {
                MessageBoxCommon.ShowDialog("无法创建Excel对象，您可能未安装Excel!", MessageBoxCommon.OK);
                return;
            }
            ExcelDll.Workbooks workbooks = xlApp.Workbooks;
            ExcelDll.Workbook workbook = workbooks.Add(ExcelDll.XlWBATemplate.xlWBATWorksheet);
            ExcelDll.Worksheet worksheet = (ExcelDll.Worksheet)workbook.Worksheets[1]; //取得sheet1

            worksheet.Cells[1, 1] = "日期";
            worksheet = mergeForeground(worksheet, "以下按照新标准登记工作分值班21小时，4月大班8小时；4月26以后就是大班中午做手术的加上中午的时间；外出送病人按时间加基础分", 1, 3, 1, 15);

            for (int i = 0; i < workHeader.Length; i++)
            {
                worksheet = mergeForeground(worksheet, workHeader[i], 2, i + 2, 2, i + 2);
            }

            for (int i = 0; i < workHeader2.Length; i++)
            {
                worksheet = mergeForeground(worksheet, workHeader2[i], 3, i + 2, 3, i + 2);
            }
            ObservableCollection<WorkScoreModel> sdsdsd = WorkScoreStatisticsCtrlViewMode.Instance.DisWorkScoreModelList;

            List<WorkScoreModel> work = new List<WorkScoreModel>();

            int sun = 0;
            foreach (var dateDD in allWoekScoreList.Keys)
            {
                List<WorkScoreModel> workScoreList = allWoekScoreList[dateDD];
                worksheet.Cells[sun + 4, 1] = dateDD;
                for (int i = 0; i < workScoreList.Count; i++)
                {
                    worksheet.Cells[sun + 4, 2] = DataManager.Instance.GetAccountNameByID(workScoreList[i].Ysxm);
                    worksheet.Cells[sun + 4, 3] = workScoreList[i].Gzjbf;
                    worksheet.Cells[sun + 4, 4] = workScoreList[i].Asa3jys;
                    worksheet.Cells[sun + 4, 5] = workScoreList[i].Pgc;
                    worksheet.Cells[sun + 4, 6] = workScoreList[i].Qymz;
                    worksheet.Cells[sun + 4, 7] = workScoreList[i].Qsmz;
                    worksheet.Cells[sun + 4, 8] = workScoreList[i].Sqfs;
                    worksheet.Cells[sun + 4, 9] = workScoreList[i].Wtwj;
                    worksheet.Cells[sun + 4, 10] = workScoreList[i].Wtrl;
                    worksheet.Cells[sun + 4, 11] = workScoreList[i].Wtcj_yqd;
                    worksheet.Cells[sun + 4, 12] = workScoreList[i].Sjmzg;
                    worksheet.Cells[sun + 4, 13] = workScoreList[i].Dmzgcy;
                    worksheet.Cells[sun + 4, 14] = workScoreList[i].Kwjzqj;
                    worksheet.Cells[sun + 4, 15] = workScoreList[i].Ynhz;
                    worksheet.Cells[sun + 4, 16] = workScoreList[i].Jh;

                    sun++;
                }
            }
            //Dictionary<int, Dictionary<int, string>> rowMapColData = QualityWorkExport.calData(startTime, endTime, accountName);
            //for (int row = 0; row < rowMapColData.Count; row++)
            //{
            //    Dictionary<int, string> colMapData = rowMapColData[row];
            //    for (int col = 0; col < 60; col++)
            //    {
            //        if (colMapData.ContainsKey(col))
            //        {
            //            string data = colMapData[col];
            //            if (null == data || data.Length == 0) continue;
            //            //Label colData = new Label(col + 1, row + 3, data, wcf_cell);
            //            worksheet.Cells[row + 4, col + 1] = data;
            //        }
            //    }
            //}

            worksheet.Columns.EntireColumn.AutoFit();
            MessageBoxCommon.ShowDialog(fileName + "保存成功", MessageBoxCommon.OK);
            if (saveFileName != "")
            {
                try
                {
                    workbook.Saved = true;
                    workbook.SaveCopyAs(saveFileName);
                }
                catch (Exception ex)
                {
                    MessageBoxCommon.ShowDialog("导出文件可能正在被打断!" + ex.Message, MessageBoxCommon.OK);
                }
            }
            xlApp.Quit();
            GC.Collect();
        }

        public static ExcelDll.Worksheet merge(ExcelDll.Worksheet worksheet, string text, int x1, int y1, int x2, int y2)
        {
            worksheet.Range[worksheet.Cells[x1, y1], worksheet.Cells[x2, y2]].Merge(worksheet.Range[worksheet.Cells[x1, y1], worksheet.Cells[x2, y2]].MergeCells);
            worksheet.Cells[x1, y1] = text;
            worksheet.Cells[x1, y1].Font.Bold = true;
            worksheet.Cells[x1, y1].HorizontalAlignment = ExcelDll.XlHAlign.xlHAlignCenter;
            worksheet.Cells[x1, y1].EntireColumn.AutoFit();
            return worksheet;
        }

        public static ExcelDll.Worksheet mergeForeground(ExcelDll.Worksheet worksheet, string text, int x1, int y1, int x2, int y2)
        {
            worksheet.Range[worksheet.Cells[x1, y1], worksheet.Cells[x2, y2]].Merge(worksheet.Range[worksheet.Cells[x1, y1], worksheet.Cells[x2, y2]].MergeCells);
            worksheet.Cells[x1, y1] = text;
            worksheet.Cells[x1, y1].Font.Bold = true;
            worksheet.Cells[x1, y1].Font.Color = new SolidColorBrush(Colors.Red);
            worksheet.Cells[x1, y1].Font.ColorIndex = new SolidColorBrush(Colors.Red);
            worksheet.Cells[x1, y1].HorizontalAlignment = ExcelDll.XlHAlign.xlHAlignCenter;
            worksheet.Cells[x1, y1].EntireColumn.AutoFit();
            return worksheet;
        }


        public static bool isOperOfAllDoctor(PatientLinkModel patientLink, string accountID)
        {
            try
            {
                AnesthesiaRecordModel anesthesiaRecord = patientLink.AnesthesiaRecord;
                if (accountID.Equals(anesthesiaRecord.Zmys))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Fmys1))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Fmys2))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Fmys3))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Mzjbys))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Xhhs1))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Xhhs2))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Xhhs3))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Xshs1))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Xshs2))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.Xshs3))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.OperDoctor1))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.OperDoctor2))
                {
                    return true;
                }
                else if (accountID.Equals(anesthesiaRecord.OperDoctor3))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                return false;
            }
        }
    }
}
